package com.example.mybatisplus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mybatisplus.model.domain.Rooms;
import com.example.mybatisplus.mapper.RoomsMapper;
import com.example.mybatisplus.model.dto.PageDTO;
import com.example.mybatisplus.model.dto.vo.RoomNumber4BuildingsVO;
import com.example.mybatisplus.model.dto.vo.Stats4RoomsVO;
import com.example.mybatisplus.service.RoomsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lxp
 * @since 2024-07-16
 */
@Service
public class RoomsServiceImpl extends ServiceImpl<RoomsMapper, Rooms> implements RoomsService {

    @Override
    public List<Stats4RoomsVO> getRoomById() {
        return baseMapper.getRoomById();
    }

    @Override
    public List<RoomNumber4BuildingsVO> getRoomByBuilding() {
        return baseMapper.getRoomByBuilding();
    }

    @Override
    public Page<Rooms> pageList(Rooms rooms, PageDTO dto) {
        QueryWrapper<Rooms> wrapper = new QueryWrapper<>();
        Page<Rooms> page =new Page<>();
        page.setCurrent(dto.getPageNo()).setSize(dto.getPagesize());
        baseMapper.selectPage(page,wrapper);
        return page;
    }
}
